<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>简答题</title>
</head>
<body>
  <div class="easyui-layout" data-options="fit:true,border:false" >
    <div data-options="region:'west',title:'题类',split:true,hideCollapsedContent:false" style="width:240px;">
      <ul id="tree_answer_questions20210420"></ul>
    </div>
    <div data-options="region:'center',border:true" >
      <table id="dg_answer_questions20210420"></table>
    </div>
  </div>

  <div id="toolbar_dg_answer_questions20210420">
    <a href="javascript:void(0)" class="easyui-linkbutton" iconCls="icon-add" plain="true" onclick="newUser()">添加</a>
    <a href="javascript:void(0)" class="easyui-linkbutton" iconCls="icon-edit" plain="true" onclick="editUser()">修改</a>
    <a href="javascript:void(0)" class="easyui-linkbutton" iconCls="icon-remove" plain="true" onclick="destroyUser()">删除</a>
  </div>

  <script>
    $(function (){
      $('#tree_answer_questions20210420').tree({
        method:'get',
        url:'./../structure/queryTreeAll',
        animate: true,
        onClick: function(node){
          //判断点击的是叶节点
          if($(this).tree('isLeaf',node.target)){
            $('#dg_answer_questions20210420').datagrid({
              url:'./../paperTwo/queryPaperTwoPid',
              queryParams: {
                pid: node.id,
                titleType:1
              }
            });
            return;
          }
        }
      });

      $('#dg_answer_questions20210420').datagrid({
        method:'get',
        fit:true,
        fitColumns:true,
        border:false,
        singleSelect:true,
        nowrap:false,//设置为 true，则把数据显示在一行里。设置为 true 可提高加载性能。
        sortName:'id',
        sortOrder:'desc',
        columns:[[
          {field:'title',title:'题目',width:160},
          {field:'answer',title:'参考答案',width:160},
          {field:'createTime',title:'创建时间',width:80,align:'center'},
          {field:'nanduxishu',title:'难易度',width:40,align:'center',
            formatter: function(value,row,index){
              if (value == 1){
                return '简单';
              }
              if (value == 2){
                return '中等';
              }
              if (value == 3){
                return '难';
              }
            }
          },
          {field:'status',title:'状态',width:40,align:'center',
            formatter: function(value,row,index){
              if(value == '1'){
                return '正常';
              }
              return '停用';
            }
          }
        ]],
        toolbar: '#toolbar_dg_answer_questions20210420',
        pagination:true,
        rownumbers:true
      });
    })
  </script>
</body>
</html>